package autopilot {	
	import com.googlecode.milib.util.MLStringUtil;
	
	/**
	 * @author Marek Brun 'minim'
	 */
	public class Building {
				public var metal:Number;		public var krysztal:Number;		
		public var time:Date;				public var buildLink:String;				public function Building(html:String) {
			//elektronicznych i stopów metali.<br>Wymagania: Metal: <b>3.298</b> Kryształ: <b>1.649</b><br>Czas ukończenia: 23min. 44sek.<br><td class=l>
			metal=Number(MLStringUtil.getBetweens(html, 'Metal: <b>', '</b> Kryszta')[0]);			krysztal=Number(MLStringUtil.getBetweens(html, '</b> Kryszta.: <b>', '</b><br>Czas')[0]);			//Czas uko.czenia: 23min. 44sek.
			var timeStr:Array=html.match(/[0-9]+(godz|min|sek)[.]/g);
			var timeNum:Array=[];
			var i:uint;
			var loopTime:String;
			for(i=0;i<timeStr.length;i++){
				loopTime=timeStr[i];
				timeNum[i]=Number(loopTime.match(/[0-9]+/)[0]);
			}			
			time=new Date(0);
			if(timeNum.length==3){
				time.setHours(timeNum[0]);
				time.setMinutes(timeNum[1]);
				time.setSeconds(timeNum[2]);
			}else if(timeNum.length==2){
				time.setMinutes(timeNum[0]);
				time.setSeconds(timeNum[1]);
			}else{
				time.setSeconds(timeNum[0]);
			}
			//<a href=index.php?page=b_building&session=5c671c7f7814&bau=1&cp=34722476><font color=#00FF00>			if(html.indexOf('b_building')>-1){
				buildLink=MLStringUtil.getBetweens(html, '<a href=', '>')[0];			}
			
		}//<>
		
	}
}
